import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Shouye',
    component: () => import('../views/Shouye.vue'),
    children: [
      {
        path: 'yonghuguanli',
        name: 'Yhgl',
        component: () => import('../views/Yhgl.vue')
      },
      {
        path: 'jueseguanli',
        name: 'Jsgl',
        component: () => import('../views/Jsgl.vue')
      },
      {
        path: 'banjiguanli',
        name: 'Bjgl',
        component: () => import('../views/Bjgl.vue')
      },
      {
        path: 'xiangmuliebiao',
        name: 'Xmlb',
        component: () => import('../views/Xmlb.vue')
      },
      {
        path: 'caidanguanli',
        name: 'Cdgl',
        component: () => import('../views/Cdgl.vue')
      },
      {
        path: 'xueshengchaxun',
        name: 'Xscx',
        component: () => import('../views/Xscx.vue')
      },
      {
        path: 'chengjichaxun',
        name: 'Cjcx',
        component: () => import('../views/Cjcx.vue')
      },
      {
        path: 'huojiangguanli',
        name: 'Hjgl',
        component: () => import('../views/Qfzcx.vue')
      },
      {
        path: 'chengjifenzu',
        name: 'Cjfz',
        component: () => import('../views/Cjfz.vue')
      },
      {
        path: 'zhanshifenzu',
        name: 'Zsfz',
        component: () => import('../views/Zsfz.vue')
      },
      {
        path: 'rizhiliebiao',
        name: 'Rzlb',
        component: () => import('../views/Rzlb.vue')
      },
      {
        path: 'qianfenzhishenhe',
        name: 'Qfzsh',
        component: () => import('../views/Qfzsh.vue')
      },
      {
        path: 'xiaoxiliebiao',
        name: 'Xxgl',
        component: () => import('../views/Xxgl.vue')
      },
      {
<<<<<<< HEAD
        path: 'jueseye',
        name: 'Jsy',
        component: () => import('../views/Jsy.vue')
      },
=======
        path: '/kechengguanli',
        name: 'Kcgl',
        component: () => import('../views/Kcgl.vue')
      },      
      {
        path: '/chengjiluru',
        name: 'Cjlr',
        component: () => import('../views/Cjlr.vue')
      },      
>>>>>>> d94b9af8a7cad897306a8cba085e691f29bffd7c
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login.vue')
  },
  {
    path: '/qianfenzhichaxun',
    name: 'Qfzcx',
    component: () => import('../views/Qfzcx.vue')
  },
  {
    path: '/qianfenzhiluru',
    name: 'Qfzlr',
    component: () => import('../views/Qfzlr.vue')
  },
  
  
  {
    path: '/qianfenzhiguize',
    name: 'Qfzgz',
    component: () => import('../views/Qfzgz.vue')
  },
  {
    path: '/zuopinzhanshi',
    name: 'Zpzs',
    component: () => import('../views/Zpzs.vue')
  },
  
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to,from,next) => {
  if (to.path != '/login') {
    if (localStorage.getItem('access_token')) {
      next();
    } else {
      next('/login');
    }
  } else {
    next();
  }
})

export default router
